package net.xmmpp.uc.im.common.constants;

import com.google.common.base.Enums;

import java.util.HashMap;
import java.util.Map;

public enum FunctionEnum{

    System(1),
    Pet(2),
    Equipment(3);

    private int id;

    private static Map<Integer,FunctionEnum> idMapping;

    static{
        idMapping = new HashMap(FunctionEnum.values().length);

        for(FunctionEnum e : values()){
            idMapping.put(e.id(), e);
        }
    }

    FunctionEnum(int id){
        this.id = id;
    }

    public int id(){
        return this.id;
    }

    public static FunctionEnum of(int id){
        return idMapping.get(id);
    }

    public static FunctionEnum getIfPresent(String name){
        return Enums.getIfPresent(FunctionEnum.class, name).orNull();
    }
}